<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>图片画廊</title>
    <style>
        .gallert{
            display: flex;
            justify-content: space-around;
            flex-wrap: wrap;
        }
        .image{
            width: 300px;
            height: 200px;
            margin: 10px;
            cursor: pointer;
        }
    </style>
</head>
<body>
    <div class="gallery">
        <img src="sg/0x300a0a0 (1).jpg" alt="Image1" class="image">
        <img src="sg/0x300a0a0 (2).jpg" alt="Image2" class="image">
        <img src="sg/t0100763700c52059ff.jpg" alt="Image3" class="image">
    </div>
    <script>
        const images = document.querySelectorAll('.image');
        //为每个图片添加点击事件监听器
        images.forEach(image => {
            image.addEventListener('click',() =>{
                const altText = image.alt;
                alert(`这张图片描述是:${altText}`);
            });
        });
    </script>
</body>
</html>